#ifndef COMMAND_H
#define COMMAND_H
#include <iostream>
#include "javabean.h"
#include <string>
using namespace std;

class Vendor{
public:
    void sailbanana(){
        cout<<"卖香蕉"<<endl;
    }
    void sailapple(){
        cout<<"卖苹果"<<endl;
    }
};

class Command{
public:
    virtual void sail()=0;
};

class BananaCommand:public Command{
    PointerPropertyBuilderByName(Vendor,v,private)
public:
    BananaCommand(Vendor* v){
        this->m_v=v;
    }
    void sail(){
        m_v->sailbanana();
    }
};

class AppleCommand:public Command{
    PointerPropertyBuilderByName(Vendor,v,private)
public:
    AppleCommand(Vendor* v){
        this->m_v=v;
    }
    void sail(){
        m_v->sailapple();
    }
};

class Waiter{
PointerPropertyBuilderByName(Command,command,private)
public:
    void sail(){
        m_command->sail();
    }
};


//int main(int argc, char *argv[])
//{
//    Vendor *v = new Vendor;
//    AppleCommand *ac = new AppleCommand(v);
//    BananaCommand *bc = new BananaCommand(v);
//    Waiter *wt = new Waiter();
//    wt->setcommand(ac);
//    wt->setcommand(bc);
//    wt->sail();
//    return 0;
//}



#endif // COMMAND_H
